package RandVars;
public class Rng {

	// (2^31)-1
	private final static int DEFAULT_MODULU = 2147483647;

	protected long a; // multiplier
	protected long z_0; // seed
	protected long c; // increment
	protected long m; // modulus

	protected long z;

	public Rng() {
		this(16807, 1, 0, DEFAULT_MODULU);
	}

	public Rng(long multiplier, long seed, long increment, long modulus) {
		a = multiplier;
		z_0 = seed;
		c = increment;
		m = modulus;
		z = z_0 ;

	}

	public Rng(int seed) {
		this(16807, seed, 0, DEFAULT_MODULU);
	}

	public double nextDouble() {
		z = (a * z + c) % m;
		return (double) z / (m - 1);
	}

}
